package com.qf.administration.controller;

import com.github.pagehelper.PageInfo;
import com.qf.administration.qo.ResourceQO;
import com.qf.administration.service.ResourceService;
import com.qf.administration.vo.ResourceVO;
import com.qf.common.base.result.RespResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @Title: ResourceController
 * @Description:
 * @author:ZWX
 * @date: 2023/5/22 10:55
 */
@Api(tags = "会议室资源管理")
@RestController
@RequestMapping("/resource")
public class ResourceController {
    @Resource
    private ResourceService resourceService;

    @ApiOperation("添加会议室信息")
    @PostMapping("/add")
    @ApiResponses({@ApiResponse(code = 200, message = "成功")})
    public RespResult<String> addResource(@RequestBody ResourceQO resourceQO) {
        return resourceService.addResource(resourceQO);
    }

    @ApiOperation("伪删除会议资源信息")
    @PutMapping("/delete")
    public RespResult<String> deleteResource(@RequestParam int[] ids) {
        return resourceService.deleteResource(ids);
    }

    @ApiOperation("修改会议资源信息")
    @PutMapping("/update")
    public RespResult<String> updateResource(@RequestBody ResourceQO resourceQO) {
        return resourceService.updateResource(resourceQO);
    }

    @ApiOperation("查询会议资源信息")
    @GetMapping("/list")
    public RespResult<PageInfo<ResourceVO>> queryResource(@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int size, @RequestParam String deviceName, @RequestParam int deviceStatus) {
        return RespResult.success(resourceService.queryResource(page, size, deviceName, deviceStatus));
    }

    @ApiOperation("查询会议资源单条信息")
    @GetMapping("/one")
    public ResourceVO queryResourceOne(@RequestParam int id) {
        return resourceService.queryResourceOne(id);
    }
}
